package org.gokeep.communication.engine.udp;

import lombok.Data;

/**
 * 消息定义
 *
 * @author xuning
 */
@Data
public class Message {
    /**
     * 消息地址
     */
    private InetAddress address;
    /**
     * 消息内容
     */
    private byte[] payload;

    /**
     * 构建器
     *
     * @return
     */
    public static Message build() {
        return new Message();
    }

    /**
     * 构建地址
     *
     * @param inetAddress
     * @return
     */
    public Message address(InetAddress inetAddress) {
        this.address = inetAddress;
        return this;
    }

    /**
     * 构建地址
     *
     * @param host
     * @param post
     * @return
     */
    public Message address(String host, int post) {
        this.address = InetAddress.build().host(host).port(post);
        return this;
    }

    /**
     * 构建消息体
     *
     * @param payload
     * @return
     */
    public Message payload(byte[] payload) {
        this.payload = payload;
        return this;
    }
}
